<%@ page import="java.sql.Statement" import="java.sql.ResultSet" import="java.sql.Connection" %>
<%@page import="connection.DBConnection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Deleted Credit Note </title>
</head>
<body>
<h2 align="center"> Deleted Credit Note </h2>
<form action="CreditPeriodicServlet">

  <%
        String exportToExcel = request.getParameter("exportToExcel");
        if (exportToExcel != null && exportToExcel.toString().equalsIgnoreCase("YES")) 
        {
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition", "inline; filename=" + "DeletedCreditNote.xls");
 
        }
    %>

<table border=1 align="center"> 
<tr>
	<th>Invoice Number</th>
	<th>Date</th>
	<th>Customer Name</th>
	<th>Customer Code</th>
	<th>Product Name</th>
	<th>Product Quantity</th>
	<th>Product Rate</th>
	<th>Net Amount</th>
	<th>Taxation Category</th>
	<th>Tax Amount</th>
	<th>Transport Charges</th>
	<th>Total Amount</th>
	<th>Rejection Reason </th>
	<th>Credit Limit</th>
</tr>

		<%  DBConnection dbc=new DBConnection();
			Connection con=dbc.getNewConnection();
			Statement st = null;
			ResultSet rs = null;
			
			double snet=0.0,stax=0.0,stransport=0.0,stotal=0.0;
			double sv8=0.0,sv10=0.0,sv11=0.0,sv12=0.0;
			
			try
			{
			   st=con.createStatement() ;
       		   rs=st.executeQuery("select * from CreditNote"); %>
	        	
       		 <%  while(rs.next()){ %>
<tr>
            		<td><%= rs.getString(1)%></td>
            		<td><%= rs.getString(2)%></td>
            		<td><%= rs.getString(3)%></td>
            		<td><%= rs.getString(4)%></td>
            		<td><%= rs.getString(5)%></td>
 					<td><%= rs.getDouble(6)%></td>
 					<td><%= rs.getDouble(7)%></td>        
 					   		
            		<% sv8=rs.getDouble(8); %>           		
            		<td><%=sv8%></td>  <%--net amount --%>
            		
            		<td><%= rs.getDouble(9)%></td>
            		
            		<% sv10=rs.getDouble(10); %>
            		<td><%=sv10%></td> <%--tax amount --%>
            		
            		<% sv11=rs.getDouble(11); %>
            		<td><%=sv11%></td> <%--transport amount --%>
            		
            		<% sv12= rs.getDouble(12); %>
            		<td><%=sv12 %></td> <%--total amount --%>
            		
            		<td><%= rs.getString(13)%></td>
            		<td><%= rs.getInt(14)%></td>
            	
            		
</tr>
        		<% 		
        			 snet=snet+sv8;
    				stax=stax+sv10;
					stransport=stransport+sv11;
					stotal=stotal+sv12;
				} %>
  
	 		<% }
			catch(Exception e){} %>
			
<tr>
	<td> <b> Total </b></td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> <%=snet %></td>
	<td> </td>
	<td> <%=stax %></td>
	<td> <%=stransport %></td>
	<td> <%=stotal %></td>
	<td> </td>
	<td> </td>
	
</tr>	
						
</table>
<br><br> 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	

    <%
        if (exportToExcel == null) {
    %>
    <a href="CreditNoteReport.jsp?exportToExcel=YES">Export to Excel</a>
    <%
        }
    %>
</form>

<br><br> 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<form name="restore_form" action="CreditNoteRestoreServlet">
<input type="text" name="restore"> 
<input type="submit" value="Restore Voucher">
</form>

</body>
</html>